#include <algorithm>
#include <cstdio>
#include <vector>
typedef __int128 int128;
constexpr int MaxN = 2e6 + 5;
constexpr int MaxM = 1e5 + 5;
int n, k;
long long p[MaxN];
long long c[MaxN];
long long b[MaxN];
int128 dp[2][MaxM];
int128 mul(long long x, long long y)
{
    int128 c = x;
    c *= y;
    return c;
}
int128 max(int128 x, int128 y)
{
    return x > y ? x : y;
}
void print(int128 x, char end='\n')
{
    std::vector<int> v;
    for (; x != 0;)
    {
        v.push_back(x % 10);
        x /= 10;
    }
    std::reverse(v.begin(), v.end());
    for (const auto &val : v)
    {
        printf("%d", val);
    }
    if (v.empty())
    {
        printf("0");
    }
    printf("%c", end);
}
void solve()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n - 1; i++)
    {
        scanf("%lld", &p[i]);
    }
    for (int i = 1; i <= k; i++)
    {
        scanf("%lld", &c[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        b[i] = 0;
    }
    int l = n - k;
    for (int i = 1; i <= k; i++)
    {
        for (int j = i; j <= i + l; j++)
        {
            b[j] += c[i];
        }
    }
    for (int i = 0; i <= p[1]; i++)
    {
        dp[1][i] = b[1] * i;
    }
    p[0] = 0x7f7f7f7f'7f7f7f7f;
    for (int i = 2; i <= n; i++)
    {
        int128 prefixMax = 0;
        for (int j = p[i - 1]; j >= 0; j--)
        {
            if (p[i - 1] - j <= p[i - 2])
            {
                prefixMax = max(prefixMax, dp[(i & 1) ^ 1][p[i - 1] - j]);
            }
            dp[i & 1][j] = prefixMax + mul(b[i], j);
        }
    }
    int128 answer = 0;
    for (int i = 0; i <= p[n - 1]; i++)
    {
        answer = max(answer, dp[n & 1][i]);
    }
    print(answer);
    return;
}
int main()
{
    freopen("festival.in", "r", stdin);
    freopen("festival.out", "w", stdout);
    int id, t;
    scanf("%d%d", &id, &t);
    for(int i = 1; i <= t; i++)
    {
        solve();
    }
    return 0;
}
